import 'package:dsp_bt_audio/common/dialog.dart';
import 'package:dsp_bt_audio/lang/my_i19n.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../tool/assets.dart';

class DialogInfomation extends DialogWidget {
  DialogInfomation({super.key});

  @override
  DialogInfomationState createState() => DialogInfomationState();
}

class DialogInfomationState extends DialogWidgetState {
  @override
  void initState() {
    super.initState();
  }

  @override
  double get height => 220;

  @override
  Widget get child {
    return Obx(() {
      List<Widget> list = ['${I19n.i.appVersion}:v1.0.0', '${I19n.i.deviceVersion}:v1.0.0', I19n.i.language]
          .map(
            (e) => SizedBox(
              height: 20,
              child: Align(alignment: Alignment.centerLeft, child: Text(e)),
            ),
          )
          .toList();

      final selection = SizedBox(
        height: 30,
        child: Row(
          spacing: 20,
          children: controller.language_list.asMap().entries.map(($0) {
            return SizedBox(
              width: 80,
              child: InkWell(
                onTap: () => controller.changeLanguage($0.key),
                child: Row(
                  spacing: 5,
                  children: [
                    Image.asset(
                      controller.currentLanguage.value == $0.key ? assets.select : assets.unselect,
                      width: 18,
                      height: 18,
                    ),
                    Text($0.value),
                  ],
                ),
              ),
            );
          }).toList(),
        ),
      );
      list.add(selection);
      return Column(crossAxisAlignment: CrossAxisAlignment.start, spacing: 10, children: list);
    });
  }
}
